vTimeWaited = 0

local vMovingTime = 0.1
local playerStartedMoving = nil
local isKeepingTrackOfTime_Moving = false

local vFallingTime = 0.1
local playerStartedFalling = nil
local isKeepingTrackOfTime_Falling = false

local vLastObjectListUpdate = 0.1
local vLastFireHackCheck = 0.1
function ccR_Frame_OnUpdate(self, elapsed)
	vTimeWaited = vTimeWaited + elapsed

	-- FH First load setup
	if not vFirstLoad 
	and (GetTime()-vLastFireHackCheck) > 1
	then
		if FireHack then
			vFirstLoad = true
			ccR.Sys.Load.Initialize()
			ccR_Timer.Register('ccR_Player_Features', ccR.Player.Features, 1)
			-- Empty Rotation, Set to 1st on list
			if ccR.Var("Rotation") == "Empty" and # DDM_List > 0 then UIDropDownMenu_SetSelectedID(DDM, 1) ccR.Var("Rotation", DDM_List[1])	end
			ccR.Sys.PrintToChat("Loaded!")
		end
		vLastFireHackCheck = GetTime()
	end
	-- Player Is Moving
	if GetTime() - vMovingTime >= 0.25 and not IsMounted() then
		if ccR.Player.Is.Moving() then
			if not isKeepingTrackOfTime_Moving then
				playerStartedMoving = GetTime()
				isKeepingTrackOfTime_Moving = true
			else
				ccR.Var("Player_Moving_Duration", GetTime() - playerStartedMoving)
			end
		else
			ccR.Var("Player_Moving_Duration", 0)
		    playerStartedMoving = nil
		    isKeepingTrackOfTime_Moving = false
		end
		vMovingTime = GetTime()
	end

	-- Player Is Falling
	if GetTime() - vFallingTime >= 0.25 then
		if ccR.Player.Is.Falling() then
			if not isKeepingTrackOfTime_Falling then
				playerStartedFalling = GetTime()
				isKeepingTrackOfTime_Falling = true
			else
				ccR.Var("Player_Falling_Duration", GetTime() - playerStartedFalling)
			end
		else
			ccR.Var("Player_Falling_Duration", 0)
		    playerStartedFalling = nil
		    isKeepingTrackOfTime_Falling = false
		end
		vFallingTime = GetTime()
	end
		
	if vTimeWaited >= ccR.Var("Rotation_Speed") then
		-- Turn off if Dead
		if ccR.Player.Is.Dead()	and ccR.Var("Toggle") then ccR.Rotation.Stop() end
		-- Start rotation if True
		if ccR.Var("Toggle") then
			if (IsFlying() and IsMounted())	or (not ccR.Var("Use_Rotation_On_Mount") and IsMounted()) then vTimeWaited = 0 return end
			ccR.Rotation.Run()
		end
		vTimeWaited = 0
	end
	
	if FireHack
	and not UnitOnTaxi("player")
	and (GetTime()-vLastObjectListUpdate) >= ccR.Var("Object_List_Delay")
	then
		ccR.Objects.Collect() 
		vLastObjectListUpdate = GetTime() 
	end

end